package com.meixiang.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;

import com.meixiang.R;
import com.meixiang.entity.ViewHolder;

/**
 * Created by zys on 2016/4/6.
 *
 *   键盘适配器
 */
public class KeyGridAdapter extends BaseAdapter {
    String[] keyList=new String[12];
    private LayoutInflater inflater;
    public KeyGridAdapter(String [] keyList,Context context){
        this.keyList=keyList;
        inflater=LayoutInflater.from(context);
    }
    @Override
    public int getCount() {
        return keyList.length;
    }

    @Override
    public Object getItem(int position) {
        return keyList[position];
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        ViewHolder viewHolder=null;
        if (convertView==null){
            convertView=inflater.inflate(R.layout.payment_key_itme,null);
            viewHolder=new ViewHolder(convertView);
            convertView.setTag(viewHolder);
        }else{
            viewHolder= (ViewHolder) convertView.getTag();
        }
        if (position==2||position==5||position==8||position==11){
            viewHolder.viewright.setVisibility(View.GONE);
        }else{
            viewHolder.viewright.setVisibility(View.VISIBLE);
        }
        if (position==9){
            convertView.setClickable(false);
            convertView.setBackgroundResource(R.color.white);
        }

        viewHolder.itemtxt.setText(keyList[position]);
        return convertView;
    }

}
